package com.etc;

import com.etc.enums.ResultStatusEnums;
import lombok.*;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @Author 武晓春
 * @Description 返回信息
 * @Date 2021/2/19  16:33
 **/

@Data
public class ResultBody {
    private Integer code;
    private String msg;
    private Object data;

    public static ResultBody ok(Object object) {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode(ResultStatusEnums.SUCCESS.getType());
        resultBody.setMsg(ResultStatusEnums.SUCCESS.getValue());
        resultBody.setData(object);
        return resultBody;
    }

    public static ResultBody ok() {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode(ResultStatusEnums.SUCCESS.getType());
        resultBody.setMsg(ResultStatusEnums.SUCCESS.getValue());
        return resultBody;
    }


    /**
     * 错误调用
     *
     * @param resultStatusEnums
     * @return
     */
    public static ResultBody error(ResultStatusEnums resultStatusEnums) {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode(resultStatusEnums.getType());
        resultBody.setMsg(resultStatusEnums.getValue());
        return resultBody;
    }
}
